-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for ART Local tests in the APIs #419
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will comment line by line, here is a few general comments mostly related to style:
- please move any non-view functions from views.py to utils.py (i.e. get_client_ip)
- you have misaligned comments e.g. lines 1166, 1169 it is harder to read code, please tab them to align with the next lines
- I think the test_type for good jobs should be also set to "grid", right now it will be "None". And related to this, there should be an extra param in query in all existing views query['test_type'] = "grid", so bigpanda takes only grid tests from the DB by default for the transition period. I think setupView() function in art/utils.py is the perfect place to add it
|
||
# log all the req params for debug | ||
_logger.debug('[ART] registerARTtest requestParams: ' + str(request.session['requestParams'])) | ||
|
||
# Checking whether params were provided | ||
if 'test_type' in request.session['requestParams']: | ||
test_type = request.session['requestParams']['test_type'] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here should be else: test_type = "grid", otherwise it end up as None. I think the "grid" should be default, at least it is needed before art expert adds this param to the art code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made "test_type" default to be "grid".
core/art/views.py
Outdated
if 'requestParams' in request.session and 'pandaid' in request.session['requestParams'] and 'testname' in request.session['requestParams']: | ||
pandaid = request.session['requestParams']['pandaid'] | ||
testname = request.session['requestParams']['testname'] | ||
elif test_type == 'local': | ||
''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is python doc string, which is used in the beginning of each function. I the middle of the code it is better to use comments with "#"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.
core/art/views.py
Outdated
# If reverse DNS lookup fails, return the IP address as fallback | ||
art_host = client_ip | ||
|
||
if art_host.split('.')[0] in art_const.AUTHORIZED_HOSTS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use of pass can be simplified by inverting the if statement, e.g.
if art_host.split('.')[0] not in art_const.AUTHORIZED_HOSTS:
return JsonResponse({"error": "Invalid ART API user!"}, status=403)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed "pass". (There were other contents here for test. I forgot to remove it in the first cleaning.).
core/art/views.py
Outdated
|
||
# Generate job ID for ART Local | ||
query = {'test_type': 'local'} | ||
localIDs = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here no need to get all pandaids from DB, it is sufficient to use aggregate functionality of Django ORM, there is an example of in remove_old_tests() view, it should be around line 1622.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to the Django ORM aggregration.
core/art/views.py
Outdated
else: | ||
pandaid = art_const.INITIAL_LOCAL_ID | ||
_logger.info("JobID: {} was generated".format(pandaid)) | ||
testname = request.session['requestParams']['testname'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line is the same for both local and grid jobs, and it is duplicated with 1158, it is better to move it out of if statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now both local and grid have the commond code.
core/art/views.py
Outdated
if 'jobname' in job: | ||
# Only check ART Grid tests | ||
if test_type and test_type == 'local': | ||
branch = concat_branch({'nightly_release_short':nightly_release_short, 'project': project, 'platform': platform}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same as testname, no need to have the same lines for both types of tests inside if. Please move it outside to avoid duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both the local and grid tests have the same code for this too.
core/art/views.py
Outdated
# Only check ART Grid tests | ||
if test_type and test_type == 'local': | ||
branch = concat_branch({'nightly_release_short':nightly_release_short, 'project': project, 'platform': platform}) | ||
attemptnr = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be moved up to around 1187
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved.
core/art/views.py
Outdated
if test_type and test_type == 'local': | ||
branch = concat_branch({'nightly_release_short':nightly_release_short, 'project': project, 'platform': platform}) | ||
attemptnr = 1 | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here it can be simple if test_type == "grid", instead of if-else, after the previous two lines moved to their places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you have added test_type == "grid" to the existing jobs in the ART tables, this has been changed as suggested.
core/art/views.py
Outdated
@@ -1265,6 +1316,8 @@ def registerARTTest(request): | |||
_logger.exception('Failed to parse date from nightly_tag') | |||
|
|||
# Check whether the pandaid has been registered already | |||
if test_type and test_type == 'local': | |||
computingsite = "ART Local" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be also moved up to ~1187, to shorten code and avoid this if statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move as suggested.
core/art/views.py
Outdated
) | ||
insertRow.save() | ||
data = {'exit_code': 0, 'message': "Provided pandaid has been successfully registered"} | ||
data = {'exit_code': 0, 'PandaID': pandaid, 'message': "Provided pandaid has been successfully registered"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see why to used capital letters here, "pandaid" should be OK. And the message may be updated, something like "Test has been registered" or something like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using pandaid in lower case now.
Thanks Tanya for reviewing the messay codes! I cleaned them quickly but
didn't take care of much details Friday. I'll address each of your comments
and commit again.
About the third general comment:
- I think the test_type for good jobs should be also set to "grid",
right now it will be "None". And related to this, there should be an extra
param in query in all existing views query['test_type'] = "grid", so
bigpanda takes only grid tests from the DB by default for the transition
period. I think setupView() function in art/utils.py is the perfect place
to add it
This is a good solution for the test and not showing the local records in
the dev instance. Because ADCR will be used for the test, the local results
will be part of it, I think the production bigpanda will still see them. Am
I wrong? (I've thought about this over the weekend and plan to ask you
about it.)
Also, if require query['test_type'] = "grid", it's good for the dev
bigpanda only rendering the webpages for ART Grid jobs. In the production
case, when merged, local and grid ART are rendered the same way (very few
places need to take special care for the local jobs, if we will use the
same display style).
Best,
Zhaoyu
…On Mon, Dec 16, 2024 at 7:55 AM Tatiana Korchuganova < ***@***.***> wrote:
***@***.**** commented on this pull request.
I will comment line by line, here is a few general comments mostly related
to style:
- please move any non-view functions from views.py to utils.py (i.e.
get_client_ip)
- you have misaligned comments e.g. lines 1166, 1169 it is harder to
read code, please tab them to align with the next lines
- I think the test_type for good jobs should be also set to "grid",
right now it will be "None". And related to this, there should be an extra
param in query in all existing views query['test_type'] = "grid", so
bigpanda takes only grid tests from the DB by default for the transition
period. I think setupView() function in art/utils.py is the perfect place
to add it
—
Reply to this email directly, view it on GitHub
<#419 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABYRK4OJ2Z3IRCLBLTGFQG32F3ESVAVCNFSM6AAAAABTSS4BTGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDKMBWGEYTMOJSGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
9006817
to
39b57ed
Compare
Thanks for your reviews! I've accomodated your suggestions to the new commit. |
No description provided.